<style>
    table {
        font-family: Arial;
        font-size: 13px;
        vertical-align: top;
    }
    th {
        font-size: 13px;
        text-align: center;
    }
    .border td, .border th {
        border-left: thin solid black;
    }
    .border th {
        border-top: thin solid black;
        border-bottom: thin solid black;
    }
    .last-border td {
        border-top: thin solid black;
        border-bottom: thin solid black;
    }
    .last-rem td {
        border-bottom: thin solid black;
    }
    .title {
        font-weight: bold;
        font-size: 20px;
        text-align: center;
    }
    td, th {
        padding: 5px 0px;
        word-break: break-word;
    }
    td {
        padding: 5px 5px;
    }
</style>
<page>
    <table cellspacing="0" cellpadding="0px" width="100%">
        <tr>
            <td colspan="5">
                <img src="http://epac.com.vn/public/images/logo.png" style="height:90px; float:left; margin-right: 10px"/>            
                EPAC Co., Ltd <br/>
                19<sup>th</sup> Floor, Indochina Park Tower <br/>
                4 Nguyen Dinh Chieu Street, Dist 1 <br/>
                Hochiminh City, Vietnam <br/>
                Tel: +(84-8) 6288 3795 | fax: +(84-8) 2220 2325 <br/>
                Email: ops@epac.com.vn | www.epac.com.vn
            </td>
        </tr>
        <tr>
            <td style="width: 3%"><br/></td>
            <td style="width: 20%"><br/></td>
            <td style="width: 10%"><br/></td>
            <td style="width: 5%"><br/></td>
            <td><br/></td>
        </tr>
        <tr>
            <td colspan="5" class="title">TRIP ACCOUNT</td>
        </tr>
        <tr>
            <td style="width: 3%"><br/></td>
            <td style="width: 15%"><br/></td>
            <td style="width: 10%"><br/></td>
            <td style="width: 5%"><br/></td>
            <td><br/></td>
        </tr>
        <tr>
            <td>
                To:
            </td>
            <td colspan="2"><?php echo $this->customer_name ?></td>
            <td>Ref.No:</td>
            <td><?php echo $this->gi->ref_no ?></td>
        </tr>
        <tr>
            <td>Vessel:</td>
            <td colspan="2"><?php echo $this->gi->vessel ?></td>
            <td>Commodities:</td>
            <td><?php echo $this->gi->commodities ?></td>            
        </tr>    
        <tr>
            <td>Flag:</td>
            <td colspan="2"><?php echo $this->gi->flag ?></td>
            <td>Quantity:</td>
            <td>
                <?php if ( $this->gi->quantity ): ?>
                    <?php if ( (int) $this->gi->quantity != $this->gi->quantity ): ?>
                        <?php echo number_format($this->gi->quantity, 2, '.', ',') ?>
                    <?php else: ?>
                        <?php echo number_format($this->gi->quantity, 0, '.', ',') ?>
                    <?php endif; ?>
                    <?php echo $this->gi->quantity_unit ?>
                <?php else: ?>
                    N/A
                <?php endif; ?>
            </td>            
        </tr>
        <tr>
            <td>Voyage No.:</td>
            <td colspan="2"><?php echo $this->gi->voyage_no ?></td>
            <td>Last port of call:</td>
            <td>
                <?php if ( $this->gi->last_port_of_call != '-1' ): ?>
                    <?php echo $this->gi->last_port_of_call ?>
                <?php else: ?>
                    N/A
                <?php endif; ?>
            </td>            
        </tr>
        <tr>
            <td>GRT:</td>
            <td colspan="2"><?php echo number_format($this->gi->gtr, 0, '.', ',') ?></td>      
            <td>Next port of call:</td>
            <td>
                <?php if ( $this->gi->next_port_of_call != '-1' ): ?>
                    <?php echo $this->gi->next_port_of_call ?>
                <?php else: ?>
                    N/A
                <?php endif; ?>
            </td>
        </tr>
        <tr>
            <td>Port of call:</td>
            <td colspan="2"><?php echo $this->port_of_call_name ?></td>
            <td>ATA:</td>
            <td>
                <?php if ( $this->gi->ata ): ?>
                    <?php echo date(DATE_FORMAT, $this->gi->ata) ?>
                <?php else: ?>
                    N/A
                <?php endif; ?>
            </td>            
        </tr>
        <tr>
            <td>Purpose of call:</td>
            <td colspan="2"><?php echo $this->gi->purpose_of_call ?></td>
            <td>ATS:</td>
            <td><?php echo date(DATE_FORMAT, $this->gi->ats) ?></td>	    
        </tr>
        <tr>
            <td><br></td>
        </tr>
        <tr class="border">
            <th width="5%">Category No.</th>
            <th colspan="2">Description</th>
            <th>Invoice number</th>
            <th style="border-right: thin solid black">Amount (USD)</th>
        </tr>
        <?php $index = 1 ?>
        <?php foreach ($this->services_detail as $service): ?>
            <tr class="border">
                <td style="text-align: center">
                    <?php echo $index++ ?>
                </td>
                <td colspan="2">
                    <?php echo $service->name ?>
                </td>
                <td style="text-align: center">
                    <?php echo $service->voucher ?>
                </td>
                <td style="text-align: right;width:20%;border-right: thin solid black">
                    <?php echo Core_Util::displayCurrrency($service->amount) ?>
                </td>
            </tr>
        <?php endforeach; ?>
        <tr class="border last-border">
            <td style="text-align: center">

            </td>
            <td style="font-weight: bold;text-align: center" colspan="2">
                Total expenses
            </td>
            <td style="text-align: center">
            </td>
            <td style="text-align: right;font-weight: bold;border-right: thin solid black">
                <?php echo Core_Util::displayCurrrency($this->total_service_amount) ?>
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <div style="margin-top: 10px">
                    Say: US dollars <?php echo Core_Util::convert_number_to_words($this->total_service_amount) ?>
                </div>
            </td>
        </tr>
        <tr><td colspan="5"><br/></td></tr>
        <tr>
            <td colspan="5">
                Remittances detail:
            </td>
        </tr>
        <tr class="border">
            <th width="2%">
                Remittance No.
            </th>
            <th>
                Date
            </th>
            <th>
                From
            </th>
            <th>
                Remarks
            </th>
            <th style="border-right: thin solid black">
                Amount (USD)
            </th>
        </tr>
        <?php $total_rem = 0 ?>
        <?php for ($i = 0; $i < $this->remittances_detail->count(); $i++): ?>
            <?php $rem = $this->remittances_detail[$i] ?>
            <tr class="border <?php echo $i == $this->remittances_detail->count() - 1 ? " last-rem" : "" ?>">
                <td style="text-align: center">
                    <?php echo $i + 1 ?>
                </td>
                <td style="text-align: center">
                    <?php echo date('d/m/Y', $rem->date) ?>
                </td>
                <td>
                    <?php echo $rem->fullname ?>
                </td>
                <td style="word-break: break-word; width: 5%">
                    <?php echo trim($rem->remarks) ?>
                </td>
                <td style="border-right: thin solid black;text-align: right">
                    <?php echo Core_Util::displayCurrrency($rem->amount) ?>
                </td>
                <?php $total_rem += $rem->amount ?>
            </tr>
        <?php endfor; ?>
        <tr><td colspan="5"><br/></td></tr>
        <tr>
            <td colspan="5">
                <?php if ( ($total_rem - $this->total_service_amount) > 0 ): ?>
                    Balance in your favour: <?php echo Core_Util::displayCurrrency(abs($total_rem - $this->total_service_amount)) ?>
                <?php else: ?>
                    Balance in our favour: <?php echo Core_Util::displayCurrrency(abs($total_rem - $this->total_service_amount)) ?>
                <?php endif; ?>
            </td>
        </tr>
        <tr>
            <td colspan="5"><br/></td>
        </tr>
        <tr>
            <td colspan="5">
                <?php if ( ($total_rem - $this->total_service_amount) > 0 ): ?>
                    Please confirm the above is in order and kindly give us instruction about the balance of <b><?php echo Core_Util::displayCurrrency($total_rem - $this->total_service_amount, 'USD ') ?></b> in your favour. 
                <?php elseif ( ($total_rem - $this->total_service_amount) < 0 ): ?>
                    Please confirm the above is in order and kindly remit us the balance of <b><?php echo Core_Util::displayCurrrency(abs($total_rem - $this->total_service_amount), 'USD ') ?></b> in our favour.<br/>
                <?php endif; ?>
            </td>
        </tr>
        <tr><td colspan="5"><br/></td></tr>
        <tr><td colspan="5"><br/></td></tr>
        <tr>
            <td colspan="2">
                <p>
                    Please be advised our bank detail is asf:<br/><br/>
                    Beneficiary name: EPAC Co.,Ltd <br/>
                    Beneficiary USD bank account: 156746989 <br/>
                    ASIA COMMERCIAL BANK - ACB <br/>
                    SWIFT CODE: ASCBVNVX <br/>
                </p>
            </td>
            <td style="text-align: center" colspan="3">
                <p>
                    Hochiminh City, <?php echo date('d/m/Y') ?><br/>
                    EPAC Port Agency<br/>
                    As Agents only<br/>
                    <br/>
                    <img src="http://www.epac.com.vn/public/images/Stamp.jpg" style="width: 200px"/>
                </p>
            </td>
        </tr>
        <tr><td colspan="5"><br/></td></tr>
        <tr><td colspan="5"><br/></td></tr>
        <tr>
            <td colspan="5">
                Thank you very much for your kind support
            </td>
        </tr>
    </table>
</page>